﻿namespace GoodAdmin.Web.Core;

/// <summary>
/// 人员管理控制器
/// </summary>
[ApiDescriptionSettings("System", Tag = "个人数据")]
[Route("system/userPersonal")]
public class UserPersonalController : IDynamicApiController
{
    private readonly ISysUserService _userService;
    private readonly IExtraUserService _extraUserService;

    public UserPersonalController(ISysUserService userService, IExtraUserService extraUserService)
    {
        _userService = userService;
        _extraUserService = extraUserService;
    }


    /// <summary>
    /// 获取登录用户信息
    /// </summary>
    /// <returns></returns>
    [HttpGet("loginUserDetail")]
    [DisplayName("获取登录用户信息")]
    [AllowLoginUser]
    public async Task<UserOutput> GetLoginUserDetail()
    {
        return await _userService.GetLoginUserDetail();
    }

    [HttpGet("getLoginUserMenuAndButton")]
    [DisplayName("获取登录用户菜单及按钮列表")]
    [AllowLoginUser]
    public async Task<dynamic> GetLoginUserMenuAndButton()
    {
        return await _userService.GetLoginUserMenuAndButton();
    }
    
    /// <summary>
    /// 修改密码
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("changePassword")]
    [DisplayName("修改密码")]
    [AllowLoginUser]
    public async Task ChangePassword(ChangePwdInput input)
    {
        await _extraUserService.ChangePassword(input);
    }
}
